//
//  EatTableViewCell.m
//  Delicious2
//
//  Created by dllo on 16/1/7.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "EatTableViewCell.h"

@implementation EatTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.titleLabel.textColor = [UIColor whiteColor];
        self.titleLabel.font = [UIFont systemFontOfSize:20];
        self.titleLabel.textAlignment = 1;
        
        self.titleImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.titleImage.layer.cornerRadius = 10;
        self.titleImage.layer.masksToBounds = YES;
        
        [self addSubview:self.titleImage];
        [self.titleImage addSubview:self.titleLabel];
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    
    self.titleImage.frame = CGRectMake(10, 10, self.frame.size.width - 20, self.frame.size.height - 20);
    
    self.titleLabel.frame = CGRectMake(0, _titleImage.frame.size.height - 30, _titleImage.frame.size.width, 30);
    [self.titleImage nightMode];
}

-(void)setEatModel:(EatModel *)eatModel {
    if (_eatModel != eatModel) {
        _eatModel = eatModel;
    }
    [self.titleImage sd_setImageWithURL:[NSURL URLWithString:eatModel.cover_image_url]  placeholderImage:[UIImage imageNamed:@"ImagePlace"]];
    
    self.titleLabel.text = eatModel.title;

}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
